CSharpTest.Net
Write(Int64,Byte[],Int32,Int32,EventWaitHandle) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Write Method : Write(Int64,Byte[],Int32,Int32,EventWaitHandle) Method

position
buffer
offset
length
signal

Glossary Item Box

Write a series of bytes to the stream at the specified position and sets the signal

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Write( _
   ByVal position As Long, _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer, _
   ByVal signal As EventWaitHandle _
) 
C# 
public void Write( 
   long position,
   byte[] buffer,
   int offset,
   int length,
   EventWaitHandle signal
)

Parameters

position
buffer
offset
length
signal

Exceptions

ExceptionDescription
System.ArgumentNullExceptionThe exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeExceptionThe exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestBackgroundWriter.cs

C#Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Write(new byte[100], 0, 100);
    wtr.Write(1, new byte[] { 42 }, 0, 1, mre);
    Assert.IsTrue(mre.WaitOne(60000, false));
    Assert.AreEqual(2, io.Position);
    Assert.AreEqual(100, io.Length);
    io.Position = 1;
    Assert.AreEqual(42, io.ReadByte());
}
VB.NETCopy Code
Using mre As New ManualResetEvent(False)
    Using io As New TestStream()
        Using wtr As New BackgroundWriter(io)
            wtr.Write(New Byte(100) {}, 0, 100)
            wtr.Write(1, New Byte() {42}, 0, 1, mre)
            Assert.IsTrue(mre.WaitOne(60000, False))
            Assert.AreEqual(2, io.Position)
            Assert.AreEqual(100, io.Length)
            io.Position = 1
            Assert.AreEqual(42, io.ReadByte())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys